package com.bush.mall.order.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.order.entity.OrderItemEntity;
import com.bush.mall.order.service.OrderItemService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 订单项信息
 * @author RUN
 * @date 2022-11-29
 */
@RestController
@RequestMapping("orderitem")
@Api(tags = "订单项信息管理" )
public class OrderItemController {

    @Resource(name= OrderItemService.BEAN_ID)
    private OrderItemService orderItemService;

    /**
     * 分页查询订单项信息列表
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "分页查询订单项信息列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return orderItemService.queryForPage(current,size);
    }

    /**
     * 保存订单项信息表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "保存订单项信息表单")
    @PostMapping
    public Result saveOrderItem(@RequestBody OrderItemEntity orderItem){
        return orderItemService.saveOrderItem(orderItem);
    }

    /**
     * 修改订单项信息表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "修改订单项信息表单")
    @PutMapping
    public Result updateOrderItem(@RequestBody OrderItemEntity orderItem){
        return orderItemService.updateOrderItem(orderItem);
    }

    /**
     * 通过指定id删除订单项信息
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "通过指定id删除订单项信息")
    @DeleteMapping
    public Result deleteOrderItem(Long id){
        return orderItemService.deleteOrderItem(id);
    }

}
